<template>
  <div class='contain'>
    <!-- <van-uploader :after-read="afterRead" ref="uploader1" v-model="fileList" multiple>
        <van-button icon="plus" type="info">上传文件</van-button>
    </van-uploader> -->
    <div class="uploadView">
        <van-uploader :max-count="10" :max-size="500 * 1024" @oversize="onOversize" :before-read="beforeRead" :after-read="afterRead" ref="uploader1" v-model="fileList" multiple />
    </div>
    <van-button type="info" @click="onClick">点击上传</van-button>
  </div>
</template>
<script>
import { Toast } from 'vant';
  import helper from '../../service/helper.js';
  import parameter from '../../service/state.js';
  export default {
    data() {
      return {
        fileList:[]
      };
    },
    components: {

    },
    methods: {
        beforeRead(file){
            console.log('beforeRead',file);
            if (file.type !== 'image/png') {
                Toast('请上传 png 格式图片');
                return false;
            }
            return true;
    },
        afterRead(file){
            console.log('afterRead',file);
        },
        onClick(file){
            console.log(file);
            this.$refs.uploader1.chooseFile();
        },
        onOversize(){
            Toast('上传文件过大')
        },
    },
    watch: {

    },
    mounted() {

    },
};
</script>
<style scoped lang="less">
.contain {
 margin: 20px auto;
 .uploadView{
     margin: 10px;
 }
}
</style>